using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.TestDrivens;
using Pixysoft.Framework.Configurations.Core;

namespace Pixysoft.Framework.Configurations.TestCases
{
    [TestDriven(TestDrivenType.IntegrationTest, "XmlCommand")]
    class UnitTest_030_XmlCommand
    {
        static IAssert assert = Assert.New(true);

        [TestStart]
        public static bool TestCaseStart()
        {
            return true;
        }

        [TestStop]
        public static void TestCaseStop()
        {
        }

        [TestStateSave]
        public static ITestDrivenDocument TestCaseStateSave()
        {
            return assert.Document;
        }

        [TestCase("ExecuteReader")]
        public static void TestCase_000_ExecuteReader()
        {
            string filename = StringHelper.default_config_basepath + StringHelper.default_config_filename;

            IXmlTree tree = new XmlTree();
            IXmlNode node = new XmlNode("log");
            node.Properties.Add("level", "fatal");
            node.Properties.Add("time", "2010-01-01");
            tree.Node.Add(node);
            tree.Save(filename);

            XmlCommand command = new XmlCommand(filename);
            command.Element = "log";
            assert.IsEqual(1, command.ExecuteReader().Node.Count);

            command = new XmlCommand(filename);
            command.Element = "log";
            command.Constraints.And<DateTime>("time").Equal(DateTime.Parse("2010-01-01"));
            assert.IsEqual(1, command.ExecuteReader().Node.Count);

            command = new XmlCommand(filename);
            command.Element = "log";
            command.Constraints.And<DateTime>("time").Equal(DateTime.Parse("2010-01-02"));
            assert.IsEqual(0, command.ExecuteReader().Node.Count);

            command = new XmlCommand(filename);
            command.Element = "log";
            command.Constraints.And<DateTime>("time").Less(DateTime.Parse("2011-01-01"));
            assert.IsEqual(1, command.ExecuteReader().Node.Count);

            assert.Write(command.Constraints.ElementName);
            assert.IsTrue(command.Constraints.HasProperty);

        }

        [TestCase("SerializeReader")]
        public static void TestCase_001_SerializeReader()
        {



            // test case for XmlCommand.SerializeReader;

        }

    }
}
